//
//  HomeTableViewCell.swift
//  GenericProjectForSwift
//
//  Created by 皮蛋菌 on 2023/5/14.
//  Copyright © 2023 漠然丶情到深处. All rights reserved.
//

import UIKit
import SnapKit

class HomeTableViewCell: UITableViewCell {
    var videoImageView: UIImageView?
    var titleLabel: UILabel?
    var sizeLabel: UILabel?
    var contact: VideoModel?
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        createSubviews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func createSubviews() {
        videoImageView = UIImageView.init()
        videoImageView?.layer.masksToBounds = true
        videoImageView?.layer.cornerRadius = LSSYRealValue(value1: 4, value2: 8)
        videoImageView?.backgroundColor = LSRedColor
        self.contentView.addSubview(videoImageView!)
        videoImageView!.snp.makeConstraints ({make in
            make.top.equalTo(self.contentView).offset(LSSYRealValue(value1: 10, value2: 20))
            make.left.equalTo(self.contentView).offset(LSSYRealValue(value1: 16, value2: 26))
            make.size.equalTo(CGSize(width: LSSYRealValue(value1: 120, value2: 240), height: LSSYRealValue(value1: 80, value2: 160)))
        })
        
        titleLabel = UILabel.init()
        titleLabel?.textColor = LSBlackColor
        titleLabel?.font = LSSystemFont(NAME: "Regular", FONTSIZE: LSSYRealValue(value1: 16, value2: 26))
        self.contentView.addSubview(titleLabel!)
        titleLabel?.snp.makeConstraints({ make in
            make.top.equalTo(videoImageView!).offset(0)
            make.left.equalTo(videoImageView!.snp.right).offset(LSSYRealValue(value1: 10, value2: 20))
            make.right.equalTo(contentView.snp.right).offset(LSSYRealValue(value1: -30, value2: -60))
        })

        sizeLabel = UILabel.init()
        sizeLabel?.textColor = LSBlackColor
        sizeLabel?.font = LSSystemFont(NAME: "Regular", FONTSIZE: LSSYRealValue(value1: 12, value2: 24))
        self.contentView.addSubview(sizeLabel!)
        sizeLabel?.snp.makeConstraints({ make in
            make.bottom.equalTo(videoImageView!.snp.bottom).offset(0)
            make.left.equalTo(videoImageView!.snp.right).offset(LSSYRealValue(value1: 10, value2: 20))
            make.right.equalTo(self.contentView.snp.right).offset(LSSYRealValue(value1: -30, value2: -60))
        })
    }
    
    func configure(for contact: VideoModel) {
        titleLabel?.text = contact.videoNameString;
        sizeLabel?.text = contact.videoSizeString;
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
